package com.fuda.trade.model
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json

@Serializable
sealed class TradeStrategyData(  ) {

    @Serializable
    data class Short(
        val volume: Int,
        val desc: String
    ) : TradeStrategyData()

    @Serializable
    data class Long(
        val volume: Int,
        val desc: String
    ) : TradeStrategyData()

    companion object {
        private val json = Json { encodeDefaults = true }

        fun serialize(command: TradeStrategyData): String {
            return json.encodeToString(command)
        }

        fun deserialize(jsonStr: String): TradeStrategyData {
            return json.decodeFromString(jsonStr)
        }
    }
}

